package com.example.e_comm.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.example.e_comm.entity.Permission;

import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.function.Function;

public interface PermissionService extends IService<Permission> {
    /**
     * 根据权限名称查询权限
     * @param page 权限名称
     * @return 权限
     */
    List<Permission> getPermissionByPage(Page<Permission> page);
    /**
     * 根据条件分页查询权限
     * @param page
     * @return keyword
     *  符合条件的权限分页列表
     */
    IPage<Permission> getPermissionByPage(Page<Permission> page, String keyword);

    List<Permission> getPermissionByUserId(Long userId);

    List<Permission> getPermissionsByRoleId(Long roleId);

    Set<String> getPermissionByUserIdSet(Long userId);

    Set<String> getPermissionByRoleIdSet(Long roleId);

    Permission getOne(QueryWrapper<Permission> queryWrapper, boolean throwEx);

    Optional<Permission> getOneOpt(QueryWrapper<Permission> queryWrapper, boolean throwEx);

    Map<String, Object> getMap(QueryWrapper<Permission> queryWrapper);

    <V> V getObj(QueryWrapper<Permission> queryWrapper, Function<? super Object, V> mapper);

    List<Permission> getPermissionByRoleId(Long roleId);
}
